package com.reider.log4AS3.layouts.converters
{
	import com.reider.log4AS3.dataholder.Log;
	
	
	/**
	 * The date pattern converter used by the PatternLayout
	 */
	
	public class DateConverter extends Converter
	{
		
		/**
		 * Converts the log.
		 * 
		 * @return The converted String
		 */
		override public function convert(log:Log):String
		{
			var time:Date = log.time
			
			var result:String = time.fullYear+"-"+fd(time.month+1)+"-"+fd(time.date)+
			" "+fd(time.hours)+":"+fd(time.minutes)+":"+fd(time.seconds)+","+time.milliseconds
			
			return result
		} 
		
		
		private function fd(num:Number):String
		{
			return String(num < 10? "0"+num : num)
		}
	}
}